<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p{
            width: 100px;
            height: 3000px;
            background-color: black;
        }
        div{
            width: 500px;
            height: 50px;
            background-color: pink;
            position: absolute;
            left: 30%;
        }
    </style>
</head>
<body>
    <div>??????</div>
    <p></p>
    <script>
        var div = document.querySelector("div")
        window.onscroll = function(){
            var num = document.documentElement.scrollTop;
            if(num<=100){
                div.style.position = "absoluted"
                div.style.top = "0px"
            }else{
            div.style.position ="fixed"
            div.style.top = "80px"
        }
        }
    </script>
</body>
</html>